package soccerscope.daistatistic.tools;

import java.io.FileWriter;
import java.io.IOException;

/**
 * 
 * a txt writer
 */
public class TextWriter {

  /**
   * 
   * saves text lines to a file
   * 
   * @param String[]
   *          the lines to save
   * @param String
   *          the file name without the .jpg extension
   */
  public static void save(String[] lines,
      String nameWithoutExtension) {

    FileWriter fw = null;

    // try to write
    try {
      fw = new FileWriter(nameWithoutExtension + ".txt", true); // a new
      // file
      // writer
      // with
      // mode
      // append
      // =
      // true

      // write all lines to file
      for (int i = 0; i < lines.length; i++) {
        fw.write(lines[i] + "\n");
      }
      fw.write("\n");
    }
    catch (IOException e) {
      System.out.println("Konnte Datei nicht erstellen");
    }
    finally {
      try {
        if (fw != null) {
          fw.close();
        }
      }
      catch (IOException e) {
      }
    }
  }
}

/**
 * $Log: TextWriter.java,v $ Revision 1.2 2006/11/05 13:58:03 wetzker more
 * merging - CLang + MF + some states still missing
 * 
 * Revision 1.1.28.2 2006/07/31 13:36:25 endert Added Java-Doc to constructors
 * if missing, minor refactorings. Revision 1.1.28.1 2006/07/26 15:28:31 endert
 * Formatted Code Revision 1.1 2006/03/13 07:38:15 axle moved from ROOT/src for
 * Maven 2 Buildsystem and Team/Soccerscope separation
 * 
 * Revision 1.4 2006/02/22 16:05:11 endert This is done: - Rebound SoccerScope
 * to Agents (can be added or removed in config-file) - Situations now all
 * extend abstract class Situation - Refactorings: ActionBean _ removed from
 * Attributes - SoccerScope will automatically connect to host given in
 * Start-Call - Trainer uses the same host as soccerscope - Removed unused stuff
 * (old confs, bat, etc.) - Code formatted (good luck when merging) - organized
 * imports - all that i forgot to mention here Revision 1.3 2005/06/20 17:30:24
 * andpaul documentation
 * 
 * Revision 1.2 2005/06/15 17:03:38 wetzker removed JIAC from Head + changes in
 * framework please report bugs or shortcomings some scenarios might not work
 * because of wrong imports
 * 
 * Revision 1.1.4.1 2005/06/15 16:45:03 wetzker final version
 * 
 * Revision 1.1 2005/06/13 11:51:37 andpaul setting up the text file writer
 * 
 * 
 */
